﻿using Microsoft.VisualStudio.TestPlatform.UnitTestFramework;
using SmarterCharger.Library.Infrastructure;
using SmarterCharger.Library.Model;
using SmarterCharger.Library.Repositories;
using SmarterCharger.Library.Repositories.Interfaces;
using SmarterCharger.Library.Tests.Unit.Infrastructure;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;

namespace SmarterCharger.Library.Tests.Integration.EnergyDeviceRepositorySpecifications
{
    public abstract class WhenGetEnergyDevices : TestBaseAsync<HttpResponseResult<IEnumerable<EnergyDevice>>>
    {
        protected IEnergyDeviceRepository EnergyDeviceRepository { get; private set; }
        protected virtual string Username { get { return TestAccount.Username; } }
        protected virtual string Password { get { return TestAccount.Password; } }

        protected override void Arrange()
        {
            EnergyDeviceRepository = new EnergyDeviceRepository();
        }

        protected override Task<HttpResponseResult<IEnumerable<EnergyDevice>>> Act()
        {
            return EnergyDeviceRepository.GetEnergyDevices(Username, Password);
        }
    }

    [TestClass]
    public class WhenGetEnergyDevicesGivenUsernameAndPasswordValid : WhenGetEnergyDevices
    {
        [TestMethod]
        public void ThenTheResultShouldNotBeEmpty()
        {
            Assert.AreEqual(HttpStatusCode.OK, Result.StatusCode);
        }
    }
}
